import 'package:flutter/material.dart' hide Page;
import 'package:flutter_custom_dialog/flutter_custom_dialog.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/screenutil_init.dart';
import 'package:oktoast/oktoast.dart';

import 'constans/route_constants.dart';
import 'init.dart';

Widget createApp() {
  return MyApp();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    initApp(context);
    //1、初始化context
    YYDialog.init(context);
    return OKToast(
        child: ScreenUtilInit(
      designSize: Size(375, 667),
      allowFontScaling: false,
      builder: () {
        return MaterialApp(
          title: 'FishDemo',
          home: RouteConstants.routes.buildPage(RouteConstants.SPLASH, null),
          builder: EasyLoading.init(),
          onGenerateRoute: (RouteSettings settings) {
            return MaterialPageRoute<Object>(builder: (BuildContext context) {
              return RouteConstants.routes
                  .buildPage(settings.name, settings.arguments);
            });
          },
        );
      },
    ));
  }
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}
